#include "Task.h"

Task::Task( void ) 
{ 
	data = new DATA_TYPE[ DATA_NUM ] ;
}

Task::Task( const Task& Obj_Task ) 
{ 
	data = new DATA_TYPE[ DATA_NUM ] ;
	for( int i = 0 ; i < DATA_NUM ; ++i )
		data[ i ] = Obj_Task.data[ i ] ;
}

Task::~Task( void ) 
{	
	if ( data != NULL )
	{
		delete [ ]data ;	
		data = NULL ;	
	}
}

Task& Task::operator = ( const Task& Obj_Task )
{
	if( this != &Obj_Task )
		for( int i = 0 ; i < DATA_NUM ; ++i )
			data[ i ] = Obj_Task.data[ i ] ;
		return *this ;
}

bool Task::operator > ( const Task& Obj_Task )
{	
	return data[ Load_time ] > Obj_Task.data[ Load_time ] ;	
}

void Task::Next_To( const Task& Obj_Task )
{	
	data[ Wait_time ] = Obj_Task.data[ Load_time ] + Obj_Task.data[ Wait_time ] ;	
}

void Task::Swap( Task& Obj_Task ) 
{
	if( this != & Obj_Task )
	{
		DATA_TYPE* temp = data ;
		data = Obj_Task.data ;
		Obj_Task.data = temp ;
	}
}

void Task::Set_Task_Data( DATA_TYPE obj_data , int Data_Pos ) 
{
	if ( Data_Pos >= 0 || Data_Pos < DATA_NUM )
	{
		this->data[ Data_Pos ] = obj_data ;
	}	
}

const DATA_TYPE& Task::Get_Task_Data( int Data_Pos ) 
{
	if ( Data_Pos >= 0 || Data_Pos < DATA_NUM )
	{
		return data[ Data_Pos ] ;
	}
}